package qst.com.bacK.pojo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.sql.Timestamp;
import java.util.List;

/**
 * Author:   msh
 * Date:     2024/10/10 上午12:11
 * Description:
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class Exam extends BaseEntity{
    private Integer testPersonnelId;
    private Integer scheduleId;
    private Timestamp beginTime;
    private Timestamp endTime;
    private Schedule schedule;
    private List<ExamQuestion> examQuestions; // 考试试题，包括试题，学生答案，本题分数等
    private String result;
    private int questionIndex;

    public ExamQuestion getQuestion() {
        if (questionIndex >= examQuestions.size()) {
            questionIndex = 0;
        } else if (questionIndex < 0) {
            questionIndex = examQuestions.size() - 1;
        }
        return examQuestions.get(questionIndex);
    }

    /**
     *
     * @return 已考时间（分钟）
     */
    public int getPassedTime() {
        return (int) (System.currentTimeMillis() - beginTime.getTime()) / (1000 * 60);
    }
}
